package com.webshopping.controller.order;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.webshopping.entry.Address;
import com.webshopping.entry.SubOrder;
import com.webshopping.entry.User;
import com.webshopping.service.address.AddressService;
import com.webshopping.service.order.SubOrderService;

@Controller
@RequestMapping("subOrder")
public class SubOrderController {
	
	@Autowired
	private SubOrderService ss;
	@Autowired
	private AddressService addService;
	
	@RequestMapping(value="getOrder")
	public ModelAndView findUserAndItemsResultMap(HttpServletRequest request){
		System.out.println(request.getParameterValues("shopCarL"));
		ModelAndView view = new ModelAndView();
        String allPrice = request.getParameter("J_Total");
        System.out.println(allPrice);
		HttpSession hs = request.getSession();
		User u = (User)hs.getAttribute("userInfoSession");
		Address address = new Address();
		address.setUserId(u.getId());
        List<SubOrder> subOrders = ss.getSubOrserInfo(request.getParameterValues("itemsFlag"));
        List<Address> addLists= addService.queryAddress(address);
        
        view.addObject("allPrice", allPrice);
		view.addObject("addLists", addLists);
		view.addObject("subOrderLists", subOrders);
		view.setViewName("../web/pay.jsp");
		return view;
	}
}
